﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using PccCommonForC;

public partial class Manager_AuthoritySign_AuthoritySign : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        if (Session["AdminUserID"] == null)
        {
            Response.Write("<script language=javascript>alert('Time is out.');window.open('../Default.aspx','_top');</script>");
            return;
        }
        if (!IsPostBack)
        {
            BindAuthorityList();
            BinDataUser();


        }
    }

    private void BindAuthorityList()
    {
        clsWebShop cls = new clsWebShop();
        ListItem item = new ListItem();
        ddlChuDe.DataSource = cls.Get_shr_AuthorityNoneProc().Tables[0];
        ddlChuDe.DataTextField = "AutNm";
        ddlChuDe.DataValueField = "AutID";
        ddlChuDe.DataBind();
        item.Text = "-- Chọn quyền hạn --";
        item.Value = "0";
        ddlChuDe.Items.Insert(0, item);
    }

    private void BinDataUser()
    {
        PccMsg msg = new PccMsg();
        msg.CreateFirstNode("CusNm", txtName.Text.Trim());
        msg.CreateFirstNode("UserNm", txtLogin.Text.Trim());
        msg.CreateFirstNode("Email", txtEmail.Text.Trim());
        msg.CreateFirstNode("AutID", ddlChuDe.SelectedValue);
        msg.CreateFirstNode("UserID", "0");
        clsWebShop cls = new clsWebShop();
        DataSet ds = null;
        ds = cls.Get_shr_UserCondition(msg.GetXmlStr);
        grv_MasterUser.DataSource = ds;
        grv_MasterUser.DataBind();

    }
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        BinDataUser();
    }

    protected void ddlChuDe_SelectedIndexChanged(object sender, EventArgs e)
    {
        BinDataUser();
    }
    protected void grv_MasterUser_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes.Add("onmouseover", "this.className='cursorOverGrid'");
            if (e.Row.RowIndex % 2 == 0)
                e.Row.Attributes.Add("onmouseout", "this.className='gvRowStyle'");
            else
                e.Row.Attributes.Add("onmouseout", "this.className='gvAlternatingRowStyle'");

        }
    }



    protected void grv_MasterUser_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        grv_MasterUser.PageIndex = e.NewPageIndex;
        BinDataUser();
    }

}
